package com.gitee.wsl.compose.base

import androidx.compose.runtime.Composable
import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

data class Dimensions(
    val tiny: Dp = 4.dp,
    val small: Dp = 8.dp,
    val medium: Dp = 16.dp,
    val large: Dp = 24.dp,
    val xLarge: Dp = 32.dp,
    val xxLarge: Dp = 40.dp,
    val xxxLarge: Dp = 48.dp,
    val divider: Dp = 1.dp,
)

val LocalDimensions: ProvidableCompositionLocal<Dimensions> = staticCompositionLocalOf { Dimensions() }

val Local.dimensions @Composable
      get() = LocalDimensions.current

@Composable
@ReadOnlyComposable
fun Dp.toSp() = with(LocalDensity.current) { this@toSp.toSp() }

